<!--功能列表-->
<template>
  <div id="MyFinList1">
    <div class="title">功能列表</div>
    <div class="content" v-for="(item, index) in indexData" :key="index">
      <div class="subTitle">{{ item.name }}</div>
      <div class="contentList">
        <ul>
          <li v-for="(item1, index1) in item.children" :key="index1" v-if="item1.isShow" @click="contentListClick(item1)">
            <span v-if="item1.num" class="angle-mark">{{ item1.num }}</span>
            <img :src="item1.icon" />
            <p style="text-align: center">{{ item1.name }}</p>
          </li>
        </ul>
      </div>
    </div>
    <div style="display: none">
      <iframe :src="openMapUrl"></iframe>
    </div>
    <van-popup v-model="shoulm">
      <div class="con_box">
        <h3>{{ text.title }}</h3>
        <p>{{ text.message }}</p>
        <div class="btnv">
          <span @click="handleClose()" v-if="text.btn.cancelText">
            {{ text.btn.cancelText }}
          </span>
          <span @click="handleOk()" v-if="text.btn.okText">
            {{ text.btn.okText }}
          </span>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import { QuerySignCallback, houseCheckFwRoleUser, houseCheckSupervisionFwRoleUser } from '@/utils/api'
let province = JSON.parse(window.localStorage.getItem('userName')).loginName == '13216111928' ||JSON.parse(window.localStorage.getItem('userName')).loginName == '18810562675'||window.localStorage.getItem('citycode') == '330000000000'
import dd from 'gdt-jsapi'
export default {
  data() {
    return {
      //农房安全角色权限
      RoleQX: '',
      baseURL: window.g.BaseURL,
      openMapUrl: '',
      cityCode: '',
      shoulm: false,
      cityCodeSCODE: '',
      cityCodeS: '',
      provisionalRole: false,
      text: {
        title: '温馨提示',
        message: '当前登录人暂无权限',
        btn: {
          okText: '确定',
          cancelText: '取消'
        }
      },
      indexData: [
        {
          name: '建房审批',
          children: [
            {
              name: '我的待办',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/1wddb.png',
              num: '0',
              isShow: true
            },
            {
              name: '我的已办',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/2.png',
              isShow: true
            },
            {
              name: '疑似危房鉴定',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/4.png',
              isShow: true
            },
            {
              name: '农村危房巡查',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/8.png',
              isShow: true
            },
            {
              name: '风险监管',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/6.png',
              isShow: JSON.parse(window.localStorage.getItem('userName')).loginName == '16635049159' ? true : false
            },
            {
              name: '建房服务',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/7.png',
              isShow: JSON.parse(window.localStorage.getItem('userName')).loginName == '16635049159' ? true : false
            },
            {
              name: '生产经营',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/5.png',
              isShow: JSON.parse(window.localStorage.getItem('userName')).loginName == '16635049159' ? true : false
            }
          ]
        },
        // {
        //   name: '农房巡查',
        //   children: [
        //     // {
        //     //   name: '安全踏勘',
        //     //   icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/1wddb.png',
        //     //   isShow: false,
        //     // },
        //     {
        //       name: '安全核查',
        //       icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/3.png',
        //       isShow: true,
        //     },
        //     // {
        //     //   name: '区县抽查',
        //     //   icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/4.png',
        //     //   isShow: false,
        //     // },
        //     // {
        //     //   name: '市级抽查',
        //     //   icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/5.png',
        //     //   isShow: false,
        //     // },
        //     // {
        //     //   name: '省级抽查',
        //     //   icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/1wddb.png',
        //     //   isShow: false,
        //     // },
        //     // {
        //     //   name: '区县督查',
        //     //   icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/4.png',
        //     //   isShow: false,
        //     // },
        //     // {
        //     //   name: '市级督查',
        //     //   icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/5.png',
        //     //   isShow: false,
        //     // },
        //     // {
        //     //   name: '省级督查',
        //     //   icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/1wddb.png',
        //     //   isShow: false,
        //     // },
        //     // {
        //     //   name: '部门协同',
        //     //   icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/1wddb.png',
        //     //   isShow: true,
        //     // },
        //     //   {
        //     //     name: '安全排查',
        //     //     icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/4.png'
        //     //   },
        //     //   {
        //     //     name: '疑似危房',
        //     //     icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/5.png'
        //     //  },
        //     //    {
        //     //      name: '危房整治',
        //     //      icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/6.png'
        //     //    }
        //   ],
        // },
        {
          name: '农房安全',
          children: [
            {
              name: '施工巡查',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/3.png',
              isShow: true
            },
            {
              name: '安全核查',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/3.png',
              isShow: JSON.parse(window.localStorage.getItem('userName')).loginName == '16635049159' ? true : false
            },
            {
              name: '房屋检查',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/4.png',
              isShow: true
            },
            {
              name: '危房改造',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/6.png',
              isShow: JSON.parse(window.localStorage.getItem('userName')).loginName == '16635049159' ? true : false
            },
            {
              name: '农房一张图',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/9.png',
              isShow: JSON.parse(window.localStorage.getItem('userName')).loginName == '16635049159' ? true : false
            }
          ]
        },
        {
          name: '农房监管',
          children: [
            {
              name: '风险监管',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/8.png',
              isShow: true
            },
            {
              name: '统计分析',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/3.png',
              isShow: true
            },
            {
              name: '一张图监管',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/1wddb.png',
              isShow: true
            },
            {
              name: '一户一档',
              icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/GNLB/3.png',
              isShow: true
            },
          ]
        },
        {
          name: '农污监管',
          children: [
            {
              name: '农污监管',
              icon: '../../../static/imgs/ZLJ/nwjg(1).png',
              isShow: true
            }
          ]
        }
      ]
    }
  },
  watch: {},
  components: {},
  computed: {},

  methods: {
    //调用存储过程
    handleClose() {
      this.shoulm = false
    },
    handleOk() {
      this.shoulm = false
    },
    getUpData: async function () {
      let paerssend = {
        procName: 'UP_PCQX',
        dtParams: JSON.stringify([{ I_USERID: Number(window.localStorage.getItem('userId')) }]),
        token: window.localStorage.getItem('token')
      }
      let paramsendMEssage = {
        accessCode: '69db6bece3a7480592e2ec753d1e335e',

        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '',
        params: paerssend
      }
      const reqwmsg = await QuerySignCallback(paramsendMEssage)
      const JSONSend = JSON.parse(reqwmsg.data.data).Data
      if (JSONSend) {
        this.provisionalRole = true
        //获取当前的citycode 区
        this.cityCode = JSONSend[0].QXCITYCODE
        //获取当前的城市名称
        // this.cityCodeS = JSONSend[0].QCITYNAME 市
        this.cityCodeSCODE = JSONSend[0].SCITYCODE
      } else {
        this.provisionalRole = false
      }
    },
    getcontentData: async function () {
      let dataArr = []
      let params = {
        dataguid: '931c475d-c6f3-41c0-8aef-28e20922db97',
        searchObject: [],
        token: window.localStorage.getItem('token')
      }
      let params1 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',

        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: params
      }
      const res = await QuerySignCallback(params1)
      if (eval('(' + res.data.data + ')').Data) {
        dataArr = eval('(' + res.data.data + ')').Data
        params.dataguid = '713761e1-74eb-4aec-8812-6b2e87fe3678'
        const res1 = await QuerySignCallback(params1)
        if (eval('(' + res1.data.data + ')').Data) {
          dataArr.push(...eval('(' + res1.data.data + ')').Data)
        }
      }
      this.indexData[0].children[0].num = dataArr.length
    },
    contentListClick(item) {
      // if(province&&item.name!='风险监管'&&item.name!='房屋检查'&&item.name!='统计分析'&&item.name!='一张图监管'&&item.name!='农污监管'){
      //   this.text={
      //     title: '温馨提示',
      //     message: '省级用户无建房审批危房改造业务操作权限。',
      //     btn: {
      //       okText: '确定',
      //       cancelText: '取消'
      //     }
      //   },
      //    this.shoulm = true
      //    return
      // }
      switch (item.name) {
        case '我的待办':
          this.$router.push({
            path: '/MyTodoList'
          })
          break
        case '我的已办':
          this.$router.push({
            path: '/MyFinList'
          })
          break
        case '疑似危房':
          this.$router.push({
            path: '/houseAppraisal'
          })
          break
        case '农房一张图':
          this.$router.push({
            path: '/oneMap'
          })
          break
        case '施工巡查':
          this.$router.push({
            path: '/ConstructionInspection'
          })
          break
        case '危房改造':
          this.$router.push({
            path: '/Houselist'
          })
          break
          case '农污监管':
            window.open('https://ncwszzd.zjjksz.com/')
          break
        case '安全排查':
          //  if(this.provisionalRole){
          this.$router.push({
            path: '/keyInvestigation',
            query: {
              cityCode: this.cityCode,
              // cityCodeS:this.cityCodeS,
              cityCodeSCODE: this.cityCodeSCODE
            }
          })
          // } else{
          //  //提示没权限
          //this.shoulm = true
          //}
          break
        case '危房整治':
          this.$router.push({
            path: '/decrepitHouse'
          })
          break
        case '安全核查':
          this.$router.push({
            path: '/toBeCheckedList'
          })
          break
        case '一户一档':
          this.$router.push({
            path: '/householdFile'
          })
          break
        case '风险监管':
          this.$router.push({
            path: '/RiskInspection'
          })
          break
        case '省级抽查':
          window.sessionStorage.setItem('SelectCity', '0')
          this.$router.push({
            path: '/inspection',
            query: {
              data: item.name
            }
          })
          break
        case '市级抽查':
          window.sessionStorage.setItem('SelectCity', '1')
          this.$router.push({
            path: '/inspection',
            query: {
              data: item.name
            }
          })
          break
        case '区县抽查':
          window.sessionStorage.setItem('SelectCityD', '2')
          this.$router.push({
            path: '/inspection',
            query: {
              data: item.name
            }
          })
          break
        case '省级督查':
          window.sessionStorage.setItem('SelectCityD', '0')
          this.$router.push({
            path: '/superinspection',
            query: {
              data: item.name
            }
          })
          break
        case '市级督查':
          window.sessionStorage.setItem('SelectCityD', '1')
          this.$router.push({
            path: '/superinspection',
            query: {
              data: item.name
            }
          })
          break
        case '区县督查':
          window.sessionStorage.setItem('SelectCityD', '2')
          this.$router.push({
            path: '/superinspection',
            query: {
              data: item.name
            }
          })
          break
        case '安全踏勘':
          this.$router.push({
            path: '/SecurityReconnaissance'
          })
          break
        case '农房督查':
          this.$router.push({
            path: '/superinspection'
          })
          break
        case '部门协同':
          this.$router.push({
            path: '/CollaborativeDepartment'
          })
          break
        case '房屋检查':
         // if (this.provisionalRole) {
            this.$router.push({
              path: '/CityList',
              query: {
                cityCode:"44130000000", //this.cityCode,
                cityCodeSCODE: this.cityCodeSCODE
              }
            })
      //     } else {
      //       //提示没权限
      //       this.text= {
      //   title: '温馨提示',
      //   message: '当前登录人暂无权限',
      //   btn: {
      //     okText: '确定',
      //     cancelText: '取消'
      //   }
      // },
      //       this.shoulm = true
      //     }
          break
        case '统计分析':
          this.$router.push({
            path: '/Statistics'
          })
          break
        case '疑似危房鉴定':
          this.$router.push({
            path: '/NotIdentified'
          })
          break
        case '农村危房巡查':
          this.$router.push({
            path: '/InspectionDilapidated'
          })
          break
        case '一张图监管':
          window.open(`https://nfzjszlb.jst.zj.gov.cn/YZTJG/#/?cityCode=${window.localStorage.getItem('citycode')}&appKey=6738c6db-69e8-11ec-a673-6805cab640a0`)
          break
        default:
          break
      }
    },
    houseCheckFwRoleUser: async function () {
      const res = await houseCheckFwRoleUser(JSON.parse(window.localStorage.getItem('userName')).loginName)
      if (res.data.code == 200) {
        debugger
        this.RoleQX = res.data.data.roleType
        this.provisionalRole = true
        this.cityCode = res.data.data.cityCode
        //获取当前的城市名称
        // this.cityCodeS = JSONSend[0].QCITYNAME 市
        this.cityCodeSCODE = res.data.data.cityName
        window.sessionStorage.setItem('citycodeRole', this.RoleQX)
        window.sessionStorage.setItem('citycodeQX', res.data.data.cityCode)
        window.sessionStorage.setItem('citycodeQXName', res.data.data.cityName)
        window.sessionStorage.setItem('userName', JSON.stringify(res.data.data))
      } else {
        this.provisionalRole = false
        this.RoleQX = -1
        window.sessionStorage.setItem('citycodeQX', '330000000000')
      }
      if (this.RoleQX == 0) {
        this.indexData[1].children[3].isShow = true
        this.indexData[1].children[2].isShow = true
        this.indexData[1].children[1].isShow = true
      } else if (this.RoleQX == 1) {
        this.indexData[1].children[2].isShow = true
        this.indexData[1].children[1].isShow = true
      } else if (this.RoleQX == 2) {
        this.indexData[1].children[1].isShow = true
      } else {
        this.indexData[1].children[3].isShow = true
        this.indexData[1].children[2].isShow = true
        this.indexData[1].children[1].isShow = true
      }
    },
    houseCheckSupervisionFwRoleUser: async function () {
      const res = await houseCheckSupervisionFwRoleUser(JSON.parse(window.localStorage.getItem('userName')).loginName)
      if (res.data.code == 200) {
        this.RoleQX = res.data.data.roleType
        window.sessionStorage.setItem('citycodeRoleD', this.RoleQX)
        window.sessionStorage.setItem('citycodeQXD', res.data.data.cityCode)
        window.sessionStorage.setItem('citycodeQXNameD', res.data.data.cityName)
        window.sessionStorage.setItem('userNameD', JSON.stringify(res.data.data))
      } else {
        this.RoleQX = -1
        window.sessionStorage.setItem('citycodeQXD', '330000000000')
      }
      if (this.RoleQX == 0) {
        this.indexData[1].children[7].isShow = true
        this.indexData[1].children[6].isShow = true
        this.indexData[1].children[5].isShow = true
      } else if (this.RoleQX == 1) {
        this.indexData[1].children[6].isShow = true
        this.indexData[1].children[5].isShow = true
      } else if (this.RoleQX == 2) {
        this.indexData[1].children[5].isShow = true
      } else {
        this.indexData[1].children[7].isShow = true
        this.indexData[1].children[6].isShow = true
        this.indexData[1].children[5].isShow = true
      }
    }
  },
  mounted() {
    this.houseCheckFwRoleUser()
    // this.houseCheckSupervisionFwRoleUser()
    window.localStorage.setItem('isGJM', true)
    this.getcontentData()
    this.openMapUrl = window.g.oneMapUrlLocation
  },
  updated() {}
}
</script>

<style lang="scss" scoped>
#MyFinList1 {
  height: 100vh;
  background: rgb(244, 244, 244);
  font-size: 20px;
  overflow: auto;
  .title {
    width: 100%;
    height: 50px;
    background: #007aff;
    line-height: 50px;
    text-align: center;
    color: #ffffff;
    font-size: 20px;
  }

  .content {
    background: #ffffff;
    padding: 10px 10px 0 10px;
    margin-bottom: 10px;
    height: auto;
    position: relative;
    overflow: hidden;
  }

  .subTitle {
    height: 40px;
    line-height: 40px;
    border-bottom: 1px solid #d2d2d2;
  }

  .contentList {
    padding-top: 10px;
    clear: both;
    overflow: hidden;
  }
  .contentList ul li {
    width: 25%;
    height: 120px;
    float: left;
    font-size: 16px;
    text-align: center;
    position: relative;

    // margin-bottom: 10px;
    .angle-mark {
      min-width: 26px;
      height: 26px;
      background: #ff0000;
      border-radius: 50%;
      display: inline-block;
      line-height: 26px;
      text-align: center;
      position: absolute;
      right: 0;
      top: -6px;
      color: #ffffff;
    }
  }

  .van-popup {
    border-radius: 10px;

    .con_box {
      width: 270px;
      line-height: 1;
      text-align: center;
      color: #4d5c82;
      padding: 15px;
      box-sizing: border-box;

      > h3 {
        font-size: 20px;
        margin-top: 10px;
        margin-bottom: 20px;
      }

      > p {
        font-size: 17px;
        margin-bottom: 30px;
      }

      .btnv {
        display: flex;
        justify-content: space-between;

        > span {
          display: block;
          width: 114px;
          background-color: #e0e5f5;
          text-align: center;
          line-height: 44px;
          font-size: 17px;
        }

        > span:last-of-type {
          background-color: #1288fe;
          color: #ffffff;
        }
      }
    }
  }
}
</style>
